package web_pro;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class stepInfo
 */
@WebServlet("/stepInfo")
public class stepInfo extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public stepInfo() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
//		response.getWriter().append("Served at: ").append(request.getContextPath());
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
	    String openid = request.getParameter("openid");
	    String step = request.getParameter("step");
	    
	    System.out.println("xcx good get  "+openid+"_____"+step);
	    Connection  conn = pub_fun.getConnection();
		PreparedStatement stmt = null;
    	String Sql_str = "update xcx_adminnew set step = '"+step+"' where openid='"+openid+"' ";
//    	Sql_str+=" values(?)";
    	try {
			stmt = conn.prepareStatement(Sql_str);
//			stmt.setString(1,step);
	        stmt.executeUpdate();
	        System.out.println("success");
	        
			Writer out = response.getWriter();
			out.write("{\"Name\":\"Sucess\",\"code\":\"200\"}");
			out.flush();
		} catch (SQLException e) {
            e.printStackTrace();
        }

	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
